package cn.logicalthing.demo.web.bean;

import com.core.bean.*;
import com.core.dao.ICarItemDao;
import com.core.dao.jdbcmysql.CarItemDao;
import com.core.dao.mybatismysql.GoodsDao;
import com.core.utils.UUIDTool;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.servlet.http.HttpServletRequest;

public class DBShoppingCar extends ShoppingCar {

    @Override
    public void save(User user, String shopId) throws Exception {
//modbus tcp java,mqtt
    }

    @Override

    public void save(User user, String shopId,String goodsId, int count) throws Exception {
        CarItem carItem = new CarItem();
        carItem.setId(UUIDTool.getUUID());
        carItem.setUid(user.getId());
        carItem.setCount(count);
        carItem.setShopid(shopId);
        GoodsDao goodsDao = new GoodsDao();
        Goods goods = goodsDao.findEntityById(goodsId);
        carItem.setGoods(goods);
        CarItemDao carItemDao = new CarItemDao();
        carItemDao.add(carItem);
    }

    public static DBShoppingCar getCar() {
        return new DBShoppingCar();
    }
}
